<template>
  <ex-dialog
    width="1200px"
    class="ex-diolog"
    :title="title"
    :visible="visible"
    :close-on-click-modal="false"
    @closeDialog="handleClose"
  >
    <div class="main" v-loading="loading">
      <el-form :model="twoForm" :rules="twoRules" ref="twoForm" label-width="140px" class="demo-ruleForm" >
        <div class="title">
          <span>消费后激励活动</span>
          <el-form-item label="活动状态：" prop="incentivePO.incentiveStatus">
              <el-switch
                v-model="twoForm.incentivePO.incentiveStatus"
                active-value="1"
                inactive-value="2"
                active-text="开启"
                inactive-text="关闭"
                >
              </el-switch>
          </el-form-item>
        </div>
        <template v-if="twoForm.incentivePO.incentiveStatus == 1">
          <el-row>
            <el-col :span="12">
              <el-form-item label="活动时间：" prop="date"> 
                <el-date-picker
                  v-model="twoForm.date"
                  @change="getTime"
                  type="datetimerange"
                  format="yyyy-MM-dd HH:mm:ss"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  placeholder="选择日期时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="" prop="checkList" label-width="0">
                <el-checkbox-group v-model="twoForm.checkList" @change="changeCheckList">
                  <div class="checkBox">
                    <el-checkbox label="1">完成每笔赚卡消费后，奖励</el-checkbox>
                    <el-form-item label="" :key="twoForm.incentivePO.cocoIncentive+ 100" :prop="twoForm.incentivePO.cocoIncentive == '1' ? 'incentivePO.cocoIncentiveAmount': ''" label-width="0">
                      <el-input placeholder="请输入" v-model="twoForm.incentivePO.cocoIncentiveAmount"></el-input>
                      <span>个COCO；前</span>
                    </el-form-item>
                    <el-form-item label="" :key="twoForm.incentivePO.cocoIncentive+ 200" :prop="twoForm.incentivePO.cocoIncentive == '1' ? 'incentivePO.cocoStock': ''" label-width="0">
                      <el-input placeholder="请输入" v-model="twoForm.incentivePO.cocoStock"></el-input>
                      <span>份完成消费可获得</span>
                    </el-form-item>
                  </div>
                  <div class="checkBox">
                    <el-checkbox label="2">完成每笔赚卡消费后，奖励</el-checkbox>
                    <el-form-item label="" :key="twoForm.incentivePO.tfIncentive+ 300" :prop="twoForm.incentivePO.tfIncentive == '1' ? 'incentivePO.tfIncentiveAmount': ''" label-width="0">
                      <el-input placeholder="请输入" v-model="twoForm.incentivePO.tfIncentiveAmount"></el-input>
                      <span>个椰分；前</span>
                    </el-form-item>
                    <el-form-item label="" :key="twoForm.incentivePO.tfIncentive+ 400" :prop="twoForm.incentivePO.tfIncentive == '1' ? 'incentivePO.tfStock': ''" label-width="0">
                      <el-input placeholder="请输入" v-model="twoForm.incentivePO.tfStock"></el-input>
                      <span>份完成消费可获得</span>
                    </el-form-item>
                  </div>
                  <div class="checkBox">
                    <el-checkbox label="3">完成每笔赚卡消费后，奖励</el-checkbox>
                    <el-form-item label="" :key="twoForm.incentivePO.medalIncentive + 500" :prop="twoForm.incentivePO.medalIncentive == 1 ? 'incentivePO.equityCardId': ''" label-width="0">
                      <el-select v-model="twoForm.incentivePO.equityCardId" placeholder="请选择" size="small" filterable @change="changeEquityCardId">
                        <el-option v-for="item in equitySelectList" :key="item.id" :label="item.value" :value="item.id">
                        </el-option>
                      </el-select>  
                      <span>勋章</span>
                    </el-form-item>
                  </div>
                </el-checkbox-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row style="margin-bottom: 20px">
            <el-col :span="24">
              <el-table :data="equityInfoList" border>
                <el-table-column label="卡名称" align="center" prop="cardName" :show-overflow-tooltip="true"/>
                <el-table-column label="卡功能" align="center" prop="functionType" :show-overflow-tooltip="true">
                  <template slot-scope="scope">
                    <dict-tag :options="functionTypeList" :value="scope.row.functionType" />
                  </template>
                </el-table-column>
                <el-table-column label="发行方" align="center" prop="issuerName" :show-overflow-tooltip="true"/>
                <el-table-column label="上链时间" align="center" prop="chainTime" :show-overflow-tooltip="true"/>
                <el-table-column label="单价" align="center" prop="price" :show-overflow-tooltip="true"/>
                <el-table-column label="库存总量" align="center" prop="total" :show-overflow-tooltip="true"/>
                <el-table-column label="剩余库存" align="center" prop="usable" :show-overflow-tooltip="true"/>
              </el-table>
            </el-col>
          </el-row>
        </template>
        <div class="title">
          <span>同行助力激励活动</span>
          <el-form-item label="活动状态：" prop="assistancePO.incentiveStatus">
              <el-switch
                v-model="twoForm.assistancePO.incentiveStatus"
                active-value="1"
                inactive-value="2"
                active-text="开启"
                inactive-text="关闭"
                >
              </el-switch>
          </el-form-item>
        </div>
        <template v-if="twoForm.assistancePO.incentiveStatus == 1">
          <el-row>
            <el-col :span="7">
              <el-form-item label="活动库存数量：" prop="assistancePO.stockStatus">
                <el-radio-group v-model="twoForm.assistancePO.stockStatus">
                  <el-radio :label="'1'">不限制</el-radio>
                    <el-radio :label="'2'">限制</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="twoForm.assistancePO.stockStatus == 2">
              <el-form-item label="" prop="assistancePO.stock" label-width="0" v-if="pathType == 'add'">
                <el-input placeholder="请输入添加库存" v-model="twoForm.assistancePO.stock">
                  <template slot="append">份</template>
                </el-input>
              </el-form-item>
              <el-form-item label="" label-width="0"  v-if="pathType == 'edit'">
                <el-input placeholder="请输入添加库存" v-model="twoForm.assistancePO.stock">
                  <template slot="append">份</template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4" v-if="pathType == 'edit' && twoForm.assistancePO.stockStatus == 2">
              <div class="stockNum">活动剩余名额: {{residueStock}}</div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="活动有效期：" >
                <div class="timeBox">
                  <el-form-item label="" label-width="0" prop="assistancePO.expirationDateHour">
                    <el-input placeholder="时" v-model="twoForm.assistancePO.expirationDateHour" />
                  </el-form-item>
                  <span> - </span>
                  <el-form-item label="" label-width="0" prop="assistancePO.expirationDateMinute">
                    <el-input placeholder="分" v-model="twoForm.assistancePO.expirationDateMinute" />
                  </el-form-item>
                  <!-- <span> - </span>
                  <el-form-item label="" label-width="0" prop="assistancePO.expirationDateSecond">
                    <el-input placeholder="秒" v-model="twoForm.assistancePO.expirationDateSecond" />
                  </el-form-item> -->
                  <span>内</span>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="inpBox">
                <el-form-item label="每份最大助力人数" prop="assistancePO.maxPeopleNum">
                  <el-input placeholder="请输入最大助力人数" v-model="twoForm.assistancePO.maxPeopleNum">
                    <template slot="append">人</template>
                  </el-input>
                </el-form-item>
                <span class="blue">（通常为套餐指定使用人数）</span>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="inpBox">
                <el-form-item label="活动奖励类型为" prop="assistancePO.integralType">
                  <el-select v-model="twoForm.assistancePO.integralType" placeholder="请选择" size="small" filterable>
                    <el-option v-for="item in integralTypeList" :key="item.id" :label="item.value" :value="item.id">
                    </el-option>
                  </el-select>
                  <span>活动保底获得</span>
                </el-form-item>
                <el-form-item label="" prop="assistancePO.guaranteeAmount" label-width="0">
                  <el-input placeholder="请输入" v-model="twoForm.assistancePO.guaranteeAmount">
                    <template slot="append" v-if="twoForm.assistancePO.integralType == 1">CoCo</template>
                    <template slot="append" v-if="twoForm.assistancePO.integralType == 2">椰分</template>
                  </el-input>
                  <span>，最多赠送</span>
                </el-form-item>
                <el-form-item label="" prop="assistancePO.maxGiveAmount" label-width="0">
                  <el-input placeholder="请输入" v-model="twoForm.assistancePO.maxGiveAmount">
                    <template slot="append" v-if="twoForm.assistancePO.integralType == 1">CoCo</template>
                    <template slot="append" v-if="twoForm.assistancePO.integralType == 2">椰分</template>
                  </el-input>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="tipsBox">根据配置保底最少积分x ，最多邀请人数 y，最多赠送积分 z(含保底) ，则新用户（z-x）/ y ±10%浮动；老用户（z-x）/ y /5 ±10%浮动</div>
            </el-col>
          </el-row>
          <el-row>
            <div class="calculateBox">
              <div class="biaoG">
                <div class="head">
                  <div>每个新用户助力而可获</div>
                  <div>每个老用户助力而可获</div>
                </div>
                <div class="head">
                  <div>{{simulationData.newMin}} ~ {{simulationData.newMax}}</div>
                  <div>{{simulationData.oldMin}} ~ {{simulationData.oldMax}}</div>
                </div>
              </div>
              <div>
                <el-button type="primary"  @click="simulation">模拟计算</el-button>
              </div>
            </div>
          </el-row>
        </template>
        <div class="title">
            <span>运营补贴活动</span>
            <el-form-item label="活动状态：">
                <el-switch
                  v-model="twoForm.subsidyVO.subsidyStatus"
                  active-value="1"
                  inactive-value="2"
                  active-text="开启"
                  inactive-text="关闭"
                  >
                </el-switch>
            </el-form-item>
          </div>
          <template v-if="twoForm.subsidyVO.subsidyStatus == 1">
            <el-row>
              <el-col :span="8">
                <el-form-item label="活动支付方式" prop="subsidyVO.payType">
                  <el-select v-model="twoForm.subsidyVO.payType" filterable placeholder="请选择活动支付方式">
                    <el-option v-for="item in payList" :key="item.id" :label="item.value" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="补贴方式" prop="subsidyVO.subsidyType">
                  <el-select v-model="twoForm.subsidyVO.subsidyType" filterable placeholder="请选择补贴方式">
                    <el-option v-for="item in subsidyList" :key="item.id" :label="item.value" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8" v-if="twoForm.subsidyVO.payType == 1">
                <el-form-item label="补贴活动价" prop="subsidyVO.cashAmount">
                  <el-input placeholder="请输入" v-model="twoForm.subsidyVO.cashAmount">
                    </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-if="twoForm.subsidyVO.payType == 2">
              <el-col :span="8">
                <el-form-item label="支付现金" prop="subsidyVO.cashAmount">
                  <el-input placeholder="请输入" v-model="twoForm.subsidyVO.cashAmount">
                    </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-if="twoForm.subsidyVO.payType == 2 || twoForm.subsidyVO.payType == 3">
              <el-col :span="8">
                <el-form-item label="支付椰分" prop="subsidyVO.integralAmount">
                  <el-input placeholder="请输入" v-model="twoForm.subsidyVO.integralAmount">
                    </el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </template>
        
      </el-form>
      <div class="button_box">
        <el-button
          type="primary"
          :loading="AgreeLoading"
          @click="submitForm('twoForm')"
        >保存，下一步</el-button>
        <el-button @click="handleClose">取消</el-button>
      </div>
    </div>
      
  </ex-dialog>
</template>
<script>
import Loading from "@/components/Loading/index";
// api
import {
  configCard,
  equityDetail,
  equitySelect,
} from "@/api/merchantsNFR/yeCard"; 
import { array } from 'jszip/lib/support';
export default {
  components: {
    Loading,
  },
  props: {
    visible: Boolean,
    id: Array,
    pathType: String,
  },
  data() {
    var checkTime = (rule, value, callback) => {
        //总库存限制数量校验
        let regNumber = /^\+?[0-9]\d*$/; //大于0的正整数
      if (value === '' ) {
        return callback(new Error("请输入时间"));
      } else if (regNumber.test(value) == false) {
        return callback(new Error("请输入大于0正整数"));
      } else if (value > 60) {
        return callback(new Error("请输入小于或等于60正整数"));
      } else {
        return callback();
      }
    };
    /* 大于0的整数 */
    var checkInteger = (rule, value, callback) => {
      //总库存限制数量校验
      let regNumber = /^\+?[1-9]\d*$/; //大于0的正整数
      if (!value ) {
        return callback(new Error("请输入"));
      } else if (regNumber.test(value) == false) {
        return callback(new Error("请输入大于0正整数"));
      } else {
        return callback();
      }
    };
    /* 大于0的两位小数 */
    var checkDecimal = (rule, value, callback) => {
      let regNumber = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/; //大于0的数值且最多保留两位小数的数值
      if (!value) {
        return callback(new Error("请输入"));
      } else if (regNumber.test(value) == false) {
        return callback(new Error("请填写大于0且最多保留两位小数的数值"));
      } else {
        return callback();
      }
      
    };
    var checkGuaranteeAmount = (rule, value, callback) => {
      let regNumber = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/; //大于0的数值且最多保留两位小数的数值
      if (!value) {
        return callback(new Error("请输入"));
      } else if (regNumber.test(value) == false) {
        return callback(new Error("请填写大于0且最多保留两位小数的数值"));
      } else if (value >= this.twoForm.assistancePO.maxGiveAmount && this.twoForm.assistancePO.maxGiveAmount ) {
        return callback(new Error("只能填写小于最多赠送的数值"));
      }else {
        return callback();
      }
      
    };
    var checkMaxGiveAmount = (rule, value, callback) => {
      var guaranteeAmount = parseFloat(this.twoForm.assistancePO.guaranteeAmount)
      var value = parseFloat(value)
      let regNumber = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/; //大于0的数值且最多保留两位小数的数值
      if (!value) {
        return callback(new Error("请输入"));
      } else if (regNumber.test(value) == false) {
        return callback(new Error("请填写大于0且最多保留两位小数的数值"));
      } else if ( guaranteeAmount >= value ) {
        console.log(111111111)
        return callback(new Error("只能填写大于保底获得的数值"));
      }else {
        return callback();
      }
      
    };
    return {
      labelWidth: "150px",
      inputWidth: "420px",
      title: "批量配置运营活动",
      loading: false,
      disabled: false,
      AgreeLoading: false,
      payList: [
        {id: '1', value: '现金支付'},
        {id: '2', value: '现金+积分支付'},
        {id: '3', value: '积分支付'},
      ],
      subsidyList: [
        {id: '1', value: '平台补贴'},
        {id: '2', value: '商户补贴'},
      ],
      twoForm: {
        checkList: [],//校验用
        //激励后消费活动
        incentivePO: {
          cocoIncentive: '2',//CoCo激励 1 开启 2 关闭
          cocoIncentiveAmount: '',//CoCo激励数额
          cocoSoldStock: '',//CoCo激励已售库存
          cocoStock: '',//CoCo激励库存
          endTime: '',//活动结束时间
          startTime: '',//活动开始时间
          equityCardId: '',//数字权益卡id
          incentiveStatus: '1',//消费后激励活动 1 开启 2 关闭
          medalIncentive: '2',//勋章激励 1 开启 2 关闭
          tfIncentive: '2',//椰分激励 1 开启 2 关闭
          tfIncentiveAmount: '',//椰分激励数额
          tfSoldStock: '',//椰分激励已售库存
          tfStock: '',//椰分激励库存
        },
        // 同行助力激励活动
        assistancePO: {
          incentiveStatus: '1',//同行助力激励状态 1 开启 2 关闭
          stockStatus: '1',//活动库存状态 1 不限制 2 限制
          stock: '',//活动库存数量
          expirationDateHour: '',//活动有效期-小时
          expirationDateMinute: '',//活动有效期-分钟
          expirationDateSecond: '0',//活动有效期-秒
          maxPeopleNum: '',//每份最大助力人数
          guaranteeAmount: '',//保底数量
          maxGiveAmount: '',//最多赠送数量

        },
        //运营补贴活动
        subsidyVO: {
          cashAmount: '',//补贴活动价/现金数额
          id: '',//商家数字权益卡id
          integralAmount: '',//积分数额
          payType: '',//活动支付方式 1现金支付 2现金+积分支付 3 积分支付
          subsidyStatus: '1',//运营补贴活动状态 1 开启 2 关闭
          subsidyType: '',//补贴方式 1 平台补贴 2 商户补贴
        },
        idList: [],//商家权益卡id列表
        date: [], //活动时间（校验用）
      },
      equityInfoList: [],
      //模拟计算数据
      simulationData: {
        newMin: 0,
        newMax: 0,
        oldMin: 0,
        oldMax: 0,
      },
      functionTypeList:[],
      equitySelectList: [],
      integralTypeList: [
        {id: '1',value: 'CoCo'},
        {id: '2',value: '椰分'},
      ],
      twoRules: {
        date: [
          {required: true,message: "请选择活动时间",trigger: ["change"]}
        ],
        'incentivePO.cocoIncentiveAmount': [
          {validator: checkDecimal,required: true,trigger: ["change"]}
        ],
        'incentivePO.cocoStock': [
          {validator: checkInteger,required: true,trigger: ["change"]}
        ],
        'incentivePO.tfIncentiveAmount': [
          {validator: checkDecimal,required: true,trigger: ["change"]}
        ],
        'incentivePO.tfStock': [
          {validator: checkInteger,required: true,trigger: ["change"]}
        ],
        'incentivePO.equityCardId': [
          { required: true,message: "请选择店铺",trigger: ["change", "bulr"]}
        ],
        'assistancePO.stock': [
          {validator: checkInteger,required: true,trigger: ["change"]}
        ],
        'assistancePO.expirationDateHour': [
          {validator: checkInteger,required: true,trigger: ["change"]}
        ],
        'assistancePO.expirationDateMinute': [
          {validator: checkTime,required: true,trigger: ["change"]}
        ],
        'assistancePO.expirationDateSecond': [
          {validator: checkTime,required: true,trigger: ["change"]}
        ],
        'assistancePO.maxPeopleNum': [
          {validator: checkInteger,required: true,trigger: ["change"]}
        ],
        'assistancePO.integralType': [
          { required: true,message: "请选择活动奖励类型",trigger: ["change", "bulr"]}
        ],
        'assistancePO.guaranteeAmount': [
          {validator: checkGuaranteeAmount,required: true,trigger: ["change"]}
        ],
        'assistancePO.maxGiveAmount': [
          {validator: checkMaxGiveAmount,required: true,trigger: ["change"]}
        ],

        'subsidyVO.payType': [
          { required: true,message: "请选择活动支付方式",trigger: ["change", "bulr"]}
        ],
        'subsidyVO.subsidyType': [
          { required: true,message: "请选择补贴方式",trigger: ["change", "bulr"]}
        ],
        'subsidyVO.cashAmount': [
          {validator: checkDecimal,required: true,trigger: ["change"]}
        ],
        'subsidyVO.integralAmount': [
          {validator: checkDecimal,required: true,trigger: ["change"]}
        ],
      },
      
    };
  },
  computed: {},
  created() {
    this.getStatusList() 
    this.getEquityList()
    console.log('this.id',this.id)
    this.twoForm.idList = this.id
  },
  mounted() {
    
  },
  computed: {},
  methods: {
    //获取活动状态字典
    getStatusList() {
      var dictType = "equity_function_type";
      this.$getSelectList(dictType)
        .then((res) => {
          var arr = [
            {
              id: "",
              value: "全部",
            },
          ];
          this.functionTypeList = arr.concat(res.result[0].dictList);
        })
        .finally(() => {});
    },
     // 获取勋章卡下拉 
    getEquityList() {
      equitySelect().then(res => {
        this.equitySelectList = res.result
      })
    },
    //取消
    handleClose(formName) {
      this.$emit("update:visible", false);
    },
    //勾选活动奖励
    changeCheckList(e){
      this.twoForm.incentivePO.cocoIncentive = 2
      this.twoForm.incentivePO.tfIncentive = 2
      this.twoForm.incentivePO.medalIncentive = 2
      console.log('e',e)
      var list = e
      list.forEach(item => {
        if(item == 1){
          this.twoForm.incentivePO.cocoIncentive = 1
        }else if(item == 2){
          this.twoForm.incentivePO.tfIncentive = 1
        }else if(item == 3){
          this.twoForm.incentivePO.medalIncentive = 1
        }else{
          // this.twoForm.incentivePO.cocoIncentive = 2
          // this.twoForm.incentivePO.tfIncentive = 2
          // this.twoForm.incentivePO.medalIncentive = 2
        }
      })
      this.$forceUpdate()
      console.log('COCO',this.twoForm.incentivePO.cocoIncentive)
      console.log('椰分',this.twoForm.incentivePO.tfIncentive)
      console.log('勋章',this.twoForm.incentivePO.medalIncentive)
    },
    changeEquityCardId(e){
      this.equityInfoList = []
      this.getequityInfo(e)
    },
    //勋章信息
    getequityInfo(id){
      equityDetail(id).then( res => {
        this.equityInfoList.push(res.result)
      })
    },
    //模拟计算
    simulation(){
      // 则新用户  （z-x）/ y     ±10%浮动；老用户  （z-x）/ y /5     ±10%浮动
      var guaranteeAmount = parseFloat(this.twoForm.assistancePO.guaranteeAmount) //活动保底获得 x
      var maxGiveAmount = parseFloat(this.twoForm.assistancePO.maxGiveAmount) // 最多赠送数量 z
      var maxPeopleNum = parseFloat(this.twoForm.assistancePO.maxPeopleNum)  //每份最大助力人数 y
      
      if(guaranteeAmount && maxGiveAmount && maxPeopleNum){
        //新用户浮动值计算
        var newNum = (maxGiveAmount - guaranteeAmount) / maxPeopleNum 
        // newNum = Math.round(newNum * 100) / 100
        var newMin = newNum - newNum * 0.1  
        var newMax = newNum + newNum * 0.1
        this.simulationData.newMin = Math.round(newMin * 100) / 100
        this.simulationData.newMax = Math.round(newMax * 100) / 100
        
        // 老用户浮动值计算
        var oldNum = (maxGiveAmount - guaranteeAmount) / maxPeopleNum / 5
        // oldNum = Math.round(oldNum * 100) / 100
        var oldMin = oldNum - oldNum * 0.1
        var oldMax = oldNum + oldNum * 0.1
        this.simulationData.oldMin = Math.round(oldMin * 100) / 100
        this.simulationData.oldMax = Math.round(oldMax * 100) / 100
      }else{
        this.$message.error(`请输入对应的只在模拟计算`);
      }
    },
    getTime(e){
      console.log("e",e)
      this.twoForm.incentivePO.startTime =  e[0] 
      this.twoForm.incentivePO.endTime = e[1]
    },
    submitForm(formName) {
      console.log(this.twoForm);
      //创建确定
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.AgreeLoading = true
          var data = {
            ...this.twoForm
          }
          configCard(data).then(res => {
            this.handleClose()
            this.$message.success('创建成功')
            this.$emit('success')
            this.AgreeLoading = false
          }).finally(()=>{
            this.AgreeLoading = false
          })
          
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    editForm(formName, status) {
      //编辑确定
      this.$refs[formName].validate(valid => {
        if (valid) {
          
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  }
};
</script>
<style lang="scss" scoped>
.ex-diolog {
  ::v-deep .ex--dialog--footer {
    border: none !important;
    padding: 0 !important;
  }

  ::v-deep .ex--dialog--main {
    padding: 10px 20px !important;
  }
}
.title{
  font-size: 18px;
  font-weight: bold;
  color: #1890ff;
  padding: 10px 0;
  border-bottom: 4px solid #1890ff;
  margin-bottom: 20px;
  display: flex;
  justify-content: flex-start;
  span{
    padding-top: 8px;
  }
}
.checkBox{
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
  .el-select{
    margin: 0 8px;
    width: 200px;
  }
  .el-input{
    width: 100px;
    margin: 0 8px;
  }
  .el-form-item{
    display: flex;
  }
}
.timeBox{
  display: flex;
  justify-content: flex-start;
  align-items: center;
  .el-input{
    width: 110px;
    margin: 0 8px;
  }
  span{
    margin: 0 8px;
  }
}
.inpBox{
  display: flex;
  justify-content: flex-start;
  // align-items: center;
  .blue{
    color: #1890ff;
    margin-top: 10px;
  }
  .el-input{
    width: 150px;
    margin: 0 8px;
  }
  .el-select{
    width: 150px;
  }
  
  ::v-deep .el-input-group__append{
    padding: 0 8px !important;
  }
}
.stockNum{
    margin: 8px 0 0 5px;
  }
.tipsBox{
  margin: 14px 0;
  color: red;
}
.calculateBox{
  display: flex;
  justify-content: center;
  .biaoG{
    margin-right: 20px;
    border: 1px solid #dfe6ec;
    .head{
      display: flex;
      width: 400px;
      border-bottom: 1px solid #dfe6ec;
      div{
        display: flex;
        flex: 1;
        justify-content: center;
        align-items: center;
        font-size: 14px;
        color: #333;
        height: 50px;
      }
      div:first-child{
        border-right: 1px solid #dfe6ec;
      }
    }
  }
}
.statusBox{
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  margin-top: 50px;

  .status{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-bottom: 50px;
    .tips{
      margin-top: 20px;
    }
  }
}
.el-select{
  width: 100%;
}
.button_box{
  display: flex;
  justify-content: center;
  margin-top: 24px;
}
</style>
